<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="/common/freqmap.jsp"%>
<%
	/**
	 * 用药详情
	 */
	String examNo = input.getDesc("sample_no", "");
	Where where = new Where("hospital=", hospital).and("sample_no=", examNo);
	List<Map> result = QBuilder.db("basedb").select("new map(patient_name as patient_name, branch_name as branch_name, sample_no as sample_no, name as name, price as price, amount as amount, unit as unit, usage as usage, content as content, time as time, card_number as card_number, way as way)").from("medicine").where(where).order("time", "desc").query().getResultObj();
    if (isEmpty(result)) {
        msg = new Message(30041, "暂无用药记录");
    } else {
		Map map = new HashMap();
		Map tempMap = result.get(0);
		for (int i = 0; i < result.size(); i++) {
			Map _map = result.get(i);
			_map.put("usage", freqMap.get(Tools.getDesc(_map.get("usage"), _map.get("usage") + "")));
		}
		map.put("time", Tools.getDesc(tempMap.get("time"), ""));
		map.put("sample_no", Tools.getDesc(tempMap.get("sample_no"), ""));
		map.put("result", result);
		List _result = new ArrayList();
		_result.add(map);
		msg.put("data", _result);
	}
	Tools.encryptPrint(out, msg.toJson());
%>
